//
//  GuideViewController.m
//  轮播图
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 沈浩. All rights reserved.
//

#import "GuideViewController.h"
#define BoundsWidth [UIScreen mainScreen].bounds.size.width
#define BoundsHeight [UIScreen mainScreen].bounds.size.height
@interface GuideViewController ()
@property(nonatomic, strong)UIScrollView *guideScrollView;
@property(nonatomic, retain)NSArray *guideArr;
@end

@implementation GuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
     self.guideArr = @[@"guide1.png", @"guide2.png", @"guide3.png"];
    [self createScrollView];
}

- (void)createScrollView {
    self.guideScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, BoundsWidth, BoundsHeight)];
        [self.view addSubview:self.guideScrollView];
        self.guideScrollView.backgroundColor = [UIColor blueColor];
        self.guideScrollView.pagingEnabled = YES;
        self.guideScrollView.showsHorizontalScrollIndicator = NO;
        self.guideScrollView.showsVerticalScrollIndicator = NO;
        self.guideScrollView.bounces = NO;
    
        self.guideScrollView.contentSize = CGSizeMake(self.guideArr.count * BoundsWidth, BoundsHeight);
           for (NSInteger i = 0; i < self.guideArr.count; i++) {
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(BoundsWidth * i, 0, BoundsWidth, BoundsHeight)];
            [self.guideScrollView addSubview:imageView];
    
            imageView.contentMode = UIViewContentModeScaleAspectFill;
            imageView.image = [UIImage imageNamed:self.guideArr[i]];
            imageView.tag = 4000 + i;
            imageView.userInteractionEnabled = YES;
    
            
    
            UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(BoundsWidth * i, BoundsHeight * 4 / 5, BoundsWidth, BoundsHeight / 5)];
            infoLabel.text = @"向左滑动进入下一页>>";
            [self.guideScrollView addSubview:infoLabel];
    
            if (i == self.guideArr.count - 1) {
                UITapGestureRecognizer *startTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(startTapAction:)];
                [imageView addGestureRecognizer:startTap];
                infoLabel.text = @"点击进入应用";
    
            }
            infoLabel.textAlignment = NSTextAlignmentCenter;
            infoLabel.textColor = [UIColor grayColor];
            infoLabel.font = [UIFont systemFontOfSize:15];
        }
        self.guideScrollView.contentOffset = CGPointMake(0, 0);
    

}
- (void)startTapAction:(UITapGestureRecognizer *)tap {
    self.block();
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
